package com.topcoder.service.studio.submission;

import java.io.Serializable;
import java.util.Date;
import java.util.Set;

import com.topcoder.service.studio.contest.Contest;
import com.topcoder.service.studio.contest.Helper;

/**
 * Represents the milestone prize id attribute of the MilestonePrize entity.
 * It's set and accessed in the set/get methods. It can be any value. The
 * default value is null
 * 
 * @author xp
 * 
 */
public class MilestonePrize implements Serializable {
    /**
     * Generated serial version id.
     */
    private static final long serialVersionUID = 979374983547774378L;

    /**
     * Represents the milestone prize id attribute of the MilestonePrize entity.
     * It's set and accessed in the set/get methods. It can be any value. The
     * default value is null
     */
    private Long milestonePrizeId;

    /**
     * Represents the create date attribute of the MilestonePrize entity. It's
     * set and accessed in the set/get methods. It can be any value. The default
     * value is null.
     */
    private Date createDate;

    /**
     * Represents the amount attribute of the MilestonePrize entity. It's set
     * and accessed in the set/get methods. It can be any value. The default
     * value is 0.
     */
    private Double amount;

    /**
     * Represents the number of submissions attribute of the MilestonePrize
     * entity. It's set and accessed in the set/get methods. It can be any
     * value. The default value is null.
     */
    private Integer numberOfSubmissions;

    /**
     * Represents the contests attribute of the MilestonePrize entity. It's set
     * and accessed in the set/get methods. It can be any value. The default
     * value is an empty HashSet
     */
    private Set<Contest> contests;

    /**
     * Represents the submissions attribute of the MilestonePrize entity. It's
     * set and accessed in the set/get methods. It can be any value. The default
     * value is an empty HashSet
     */
    private Set<Submission> submissions;

    /**
     * Represents the type attribute of the MilestonePrize entity. It's set and
     * accessed in the set/get methods. It can be any value. The default value
     * is null.
     */
    private PrizeType type;

    /**
     * Default constructor.
     */
    public MilestonePrize() {
    }

    /**
     * Returns the milestonePrizeId.
     * 
     * @return the milestonePrizeId.
     */
    public Long getMilestonePrizeId() {
        return milestonePrizeId;
    }

    /**
     * Updates the milestonePrizeId with the specified value.
     * 
     * @param milestonePrizeId
     *            the milestonePrizeId to set.
     */
    public void setMilestonePrizeId(Long milestonePrizeId) {
        this.milestonePrizeId = milestonePrizeId;
    }

    /**
     * Returns the createDate.
     * 
     * @return the createDate.
     */
    public Date getCreateDate() {
        return createDate;
    }

    /**
     * Updates the createDate with the specified value.
     * 
     * @param createDate
     *            the createDate to set.
     */
    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    /**
     * Returns the amount.
     * 
     * @return the amount.
     */
    public Double getAmount() {
        return amount;
    }

    /**
     * Updates the amount with the specified value.
     * 
     * @param amount
     *            the amount to set.
     */
    public void setAmount(Double amount) {
        this.amount = amount;
    }

    /**
     * Returns the numberOfSubmissions.
     * 
     * @return the numberOfSubmissions.
     */
    public Integer getNumberOfSubmissions() {
        return numberOfSubmissions;
    }

    /**
     * Updates the numberOfSubmissions with the specified value.
     * 
     * @param numberOfSubmissions
     *            the numberOfSubmissions to set.
     */
    public void setNumberOfSubmissions(Integer numberOfSubmissions) {
        this.numberOfSubmissions = numberOfSubmissions;
    }

    /**
     * Returns the contests.
     * 
     * @return the contests.
     */
    public Set<Contest> getContests() {
        return contests;
    }

    /**
     * Updates the contests with the specified value.
     * 
     * @param contests
     *            the contests to set.
     */
    public void setContests(Set<Contest> contests) {
        this.contests = contests;
    }

    /**
     * Returns the submissions.
     * 
     * @return the submissions.
     */
    public Set<Submission> getSubmissions() {
        return submissions;
    }

    /**
     * Updates the submissions with the specified value.
     * 
     * @param submissions
     *            the submissions to set.
     */
    public void setSubmissions(Set<Submission> submissions) {
        this.submissions = submissions;
    }

    /**
     * Returns the type.
     * 
     * @return the type.
     */
    public PrizeType getType() {
        return type;
    }

    /**
     * Updates the type with the specified value.
     * 
     * @param type
     *            the type to set.
     */
    public void setType(PrizeType type) {
        this.type = type;
    }
    
    /**
     * Compares this object with the passed object for equality. Only the id
     * will be compared.
     * 
     * @param obj
     *            the {@code Object} to compare to this one
     * @return true if this object is equal to the other, {@code false} if not
     */
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Contest) {
            return getMilestonePrizeId() == ((MilestonePrize) obj)
                    .getMilestonePrizeId();
        }
        return false;
    }

    /**
     * Overrides {@code Object.hashCode()} to provide a hash code consistent
     * with this class's {@link #equals(Object)}} method.
     * 
     * @return a hash code for this {@code Contest}
     */
    @Override
    public int hashCode() {
        return Helper.calculateHash(milestonePrizeId);
    }
}
